*******************************************************************************************
* Aarøe, Petersen & Arceneaux 2020
* replication dofile for the results from the 2013 US sample 2
*******************************************************************************************

clear 
set more off

* use the following replication data set
use "Replication dataset for the US 2013 sample 2.dta", replace

*******************************************************************************************
* Recodings
*******************************************************************************************

*Contamination disgust sensitivity from the DS-R
recode ds1_4 (5=5) (1=1) (2=2) (3=3) (4=4), gen(toilet04)
recode ds1_9 (5=5) (1=1) (2=2) (3=3) (4=4), gen(cook09)
recode ds2_4 (5=5) (1=1) (2=2) (3=3) (4=4), gen(soda18)
recode ds2_9 (5=5) (1=1) (2=2) (3=3) (4=4), gen(chocl23)
recode ds2_12 (5=5) (1=1) (2=2) (3=3) (4=4), gen(condom26)


alpha toilet04 cook09 soda18 chocl23 condom26
egen contam_av = rowmean(toilet04 cook09 soda18 chocl23 condom26)
gen contam_av01 =(contam_av-1)/4

* The germ aversion factor 
recode pvds_8-pvds_15 (19=1) (20=2) (21=3) (22=4) (23=5) (24=6) (25=7)

tempvar p12 p14 p15
gen `p12'=8-pvds_12
gen `p14'=8-pvds_14
gen `p15'=8-pvds_15

alpha pvds_8 pvds_9 pvds_10 pvds_11 `p12' pvds_13 `p14' `p15'

egen Germ=rowmean(pvds_8 pvds_9 pvds_10 pvds_11 `p12' pvds_13 `p14' `p15')
drop __*
gen Germ01=(Germ-1)/6
ta Germ01

*The Pathogen Disgust Scale from the TDDS
alpha pathogen_1-pathogen_7
egen PathogenDisgust=rowmean(pathogen_1-pathogen_7)
gen PathogenDisgust01=(PathogenDisgust-1)/6
sum PathogenDisgust01
gen pathogen01 =PathogenDisgust01

egen combinedscale=rmean(Germ01 PathogenDisgust01 contam_av01)
alpha Germ01 PathogenDisgust01 contam_av01
sum combinedscale

**Party identification 
gen pid7=1 if demintsty==1
replace pid7=2 if demintsty==2
replace pid7=3 if leaners==2
replace pid7=4 if leaners==3
replace pid7=5 if leaners==1
replace pid7=6 if repintsty==2
replace pid7=7 if repintsty==1

gen pid701=(pid7-1)/6
ta pid701

* age
gen age=2013-(1911+dob)

* gender
gen female=0
replace female=1 if sex==2

* Household income
gen houseincome01=(income-1)/9

* Education
gen education1 = education
recode education1 (4=3) (5=4) (6=5)
gen education01=(education1-1)/4

* ideology
gen conservative = ideology
sum conservative
gen ideo01=(conservative-1)/4

* race
gen race5=race
recode race5 (1=2) (2=1) (3=3) (4=4) (5=5) (6=5)
label define race5 1 "White" 2 "Black" 3 "Latino/Hispanic" 4 "Asian" 5 "Other"
label values race5 race5

gen white = race5
recode white (1=1) (2=0) (3=0) (4=0) (5=0)
gen black = race5
recode black (1=0) (2=1) (3=0) (4=0) (5=0)
gen hispanic = race5
recode hispanic (1=0) (2=0) (3=1) (4=0) (5=0)
gen asian = race5
recode asian (1=0) (2=0) (3=0) (4=1) (5=0)

* Big five personality traits
recode tipi_1 tipi_2 tipi_3 tipi_4 tipi_5 tipi_6 tipi_7 tipi_8 /*
*/ (1=11) (2=10) (3=9) (4=8) (5=7) (6=6) (7=5) (8=4) (9=3) (10=2) (11=1)

egen openness=rmean(tipi_1 tipi_2)
egen conscient=rmean(tipi_3 tipi_4)
egen extraversion=rmean(tipi_5 tipi_6)
egen agreeableness= rmean(tipi_7 tipi_8) 
egen neuroticism=rmean(tipi_9 tipi_10)
gen openness01=(openness-1)/10
gen conscient01=(conscient-1)/10
gen extraversion01=(extraversion-1)/10
gen agreeableness01=(agreeableness-1)/10
gen neuroticism01=(neuroticism-1)/10


*********************************************************************************************
* Descriptive statistics and analyses
*********************************************************************************************

* number of respondents
ta consent

* sample descriptives
sum female
sum age 
ta education1
ta income
ta race5
sum ideo01

eststo clear
estpost tabstat combinedscale contam_av01 pathogen01 Germ01, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear

eststo clear
estpost tabstat pid701, statistics(mean sd N) columns(statistics)
esttab . , cells("mean sd N"), using part_2.rtf, replace
eststo clear


* Average marginal effects for Figure 1 in the main text
* The average marginal effects are also reported on Online Appendix A3.1.1
* the estimates were included in the dataset for the metaanalysis of effects of pathogen avoidance motivation on party preferences
quietly reg pid701 combinedscale female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(combinedscale education01 houseincome01 openness01 conscient01 agreeableness01) level (90) post

quietly reg pid701 contam_av01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(contam_av01  education01 houseincome01 openness01 conscient01 agreeableness01) level (90) post

quietly reg pid701 pathogen01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(pathogen01  education01 houseincome01 openness01 conscient01 agreeableness01) level (90) post

quietly reg pid701 Germ01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(Germ01  education01 houseincome01 openness01 conscient01 agreeableness01) level (90) post


* Analyses for Table A8
eststo clear
eststo: reg pid701 combinedscale female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
eststo: reg pid701 contam_av01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
eststo: reg pid701 pathogen01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
eststo: reg pid701 Germ01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.1 ** 0.02 *** 0.002) wide constant r2
eststo clear


* Analyses of robustness for Figure A2 reported in Online Appendix A3.2
eststo clear
eststo: reg pid701 female houseincome01 education01 age i.race5, level (90)
margins, dydx(education01 houseincome01)
eststo: reg pid701 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)
margins, dydx(education01 houseincome01 openness01 conscient01 agreeableness01)
 
reg pid701 pathogen01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90)
gen miss2=e(sample)

quietly reg pid701 combinedscale female houseincome01 education01 age i.race5 if miss2 ==1, level (90)
margins, dydx(combinedscale)
quietly reg pid701 contam_av01 female houseincome01 education01 age i.race5 if miss2 ==1, level (90)
margins, dydx(contam_av01)
quietly reg pid701 pathogen01 female houseincome01 education01 age i.race5 if miss2 ==1, level (90)
margins, dydx(pathogen01)
quietly reg pid701 Germ01 female houseincome01 education01 age i.race5 if miss2 ==1, level (90)
margins, dydx(Germ01)


* Supplemental analyses of attitudes on social issues as a pathway linking pathogen avoidance motivation and partisanship
* reported in A3.3, Figure A3

quietly reg ideo01 combinedscale female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(combinedscale)
quietly reg ideo01 contam_av01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(contam_av01)
quietly reg ideo01 pathogen01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(pathogen01)
quietly reg ideo01 Germ01 female houseincome01 education01 age i.race5 openness01 conscient01 extraversion01 agreeableness01 neuroticism01, level (90) 
margins, dydx(Germ01)


